//
//  ZHConstHeader.h
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 ZHBen. All rights reserved.
//

#ifndef ZHConstHeader_h
#define ZHConstHeader_h
#import "KBaseTools.h"
#import "YYModel.h"

#define KExecuteBlock(block,...) (block ? block(__VA_ARGS__) : nil)

#define KExecuteBlockOnMain(block,...) if(block){if([NSThread isMainThread]){block(__VA_ARGS__);}else{dispatch_async(dispatch_get_main_queue(),^{block(__VA_ARGS__);});}}

#define KNSCodingImpl \
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; } \
- (id)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self yy_modelInitWithCoder:aDecoder]; }

#define KNSCopyingImpl \
- (id)copyWithZone:(NSZone *)zone { return [self yy_modelCopy]; }


///数组添加nullable对象
#define kArrayAddObj(_array_, _obj_) if(_obj_!=nil)[_array_ addObject:_obj_]
///防越界数组取值
#define kObjectFromArray(array,index)     [KBaseTools objectFromArray:array atIndex:index]

#endif /* ZHConstHeader_h */
